package tr.richfacesext.components.rating;

import javax.faces.component.UIComponent;
import javax.faces.webapp.UIComponentTag;

import tr.richfacesext.components.ComponentUtils;

/**
 * 
 * @author mert
 *
 */
public class RatingTag extends UIComponentTag {

	private String _value = null;
	private String _converter = null;
	private String _immediate = null;
	private String _required = null;
	private String _validator = null;
	private String _valueChangeListener = null;
	private String _saveRatingMethod = null;
	private String _fixedValue = null;
	private String _onSuccessJSCall = null;

	public void release(){
		super.release();
		_value = null;
		_converter = null;
		_immediate = null;
		_required = null;
		_validator = null;
		_valueChangeListener = null;
		_saveRatingMethod = null;
		_fixedValue = null;
		_onSuccessJSCall = null;
	}

	protected void setProperties(UIComponent uicomponent){
		super.setProperties(uicomponent);

		ComponentUtils.setValueProperty(getFacesContext(), uicomponent, _value);
		ComponentUtils.setConverterProperty(getFacesContext(), uicomponent, _converter);
		ComponentUtils.setImmediateProperty(getFacesContext(), uicomponent, _immediate);
		ComponentUtils.setRequiredProperty(getFacesContext(), uicomponent, _required);
		ComponentUtils.setValidatorProperty(getFacesContext(), uicomponent, _validator);
		ComponentUtils.setValueChangeListenerProperty(getFacesContext(), uicomponent, _valueChangeListener);
		ComponentUtils.setStringProperty(getFacesContext(), uicomponent, "saveRatingMethod", _saveRatingMethod);
		ComponentUtils.setBooleanProperty(getFacesContext(), uicomponent, "fixedValue", _fixedValue);
		ComponentUtils.setStringProperty(getFacesContext(), uicomponent, "onSuccessJSCall", _onSuccessJSCall);
	}
	
	public String getComponentType() {
		return RatingConstants.COMPONENT_TYPE;
	}

	public String getRendererType() {
		return RatingConstants.DEFAULT_RENDERER;
	}

	public void setValue(String value){
		_value = value;
	}

	public void setConverter(String value){
		_converter = value;
	}

	public void setImmediate(String value){
		_immediate = value;
	}

	public void setRequired(String value){
		_required = value;
	}

	public void setValidator(String value){
		_validator = value;
	}

	public void setValueChangeListener(String value){
		_valueChangeListener = value;
	}

	public void setSaveRatingMethod(String value) {
		_saveRatingMethod = value;
	}
	
	public void setFixedValue(String value) {
		_fixedValue = value;
	}
	
	public void setOnSuccessJSCall(String value) {
		_onSuccessJSCall = value;
	}
}